/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: jse2302 - ArrSort2
 * <p>Powered by webrx On 2023-06-14 11:29:43
 * <p>Created by IntelliJ IDEA
 *
 * @author  webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class ArrSort2 {
    public static void main(String[] args) {
        int[] n1 = {4, 3, 2, 1, 0};
        //System.out.println(Arrays.toString(n1));
        //默认排序为升序
        //Arrays.sort(n1);
        //System.out.println(Arrays.toString(n1));

        Integer[] n2 = {4, 3, 2, 1, 0};
        System.out.println(Arrays.toString(n2));

        //洗牌
        Arrays.sort(n2, (a, b) -> Math.random() > .5 ? 1 : -1);
        System.out.println(Arrays.toString(n2));

        //升序
        Arrays.sort(n2);
        System.out.println(Arrays.toString(n2));

        //降序
        Arrays.sort(n2, (a, b) -> b - a);
        System.out.println(Arrays.toString(n2));
    }
}
